#################################################################################
#                                                                               #
# Copyright (c) 2007 Luca Bruno                                                 #
#                                                                               #
# This file is part of Smalltalk YX.                                            #
#                                                                               #
# Permission is hereby granted, free of charge, to any person obtaining a copy  #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights  #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell     #
# copies of the Software, and to permit persons to whom the Software is         #
# furnished to do so, subject to the following conditions:                      #
#                                                                               #
# The above copyright notice and this permission notice shall be included in    #
# all copies or substantial portions of the Software.                           #
#                                                                               #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR    #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,      #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE   #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER        #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING       #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER           #
# DEALINGS IN THE SOFTWARE.                                                     #
#                                                                               #
#################################################################################

import os
Import ('env', 'distdir')

prog_sources = Split ("main.c")
prog_resources = Split ("syx.ico resources.rc")
prog_objects = [env.Object (prog_sources)]

if env['PLATFORM'] == 'win32':
    prog_objects.append (env.RES ('resources.rc'))
    
prog = env.Program (target='syx', source=prog_objects, LIBS=['syx'])
Default (prog)

inst = env.SyxInstall (env['bindir'], prog)

# Create the image once installed

image = env.Command (env['imagepath'], inst, '$SOURCE -r $datadir -S')
env.Alias ('install', image)
env.AlwaysBuild (image)
env.Depends (image, os.path.join(env['datadir'], 'st'))

# Distribution

if env['PLATFORM'] != 'win32':
    bimage = env.Command (os.path.join (distdir, env['imagepath']), inst, '$SOURCE -r $distdir/$datadir -i $TARGET -S')
    env.Depends (bimage, image)
    env.NoClean (image, bimage)
    env.Alias ('bdist', bimage)

target = env.Install (os.path.join (distdir, 'src'), prog_sources + prog_resources + ['SConscript'])
env.Alias ('sdist', target)
